using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public abstract class LogicalEffectBase : MonoBehaviour
{
    // 数据
    public LogicalEffectDataBase effectData;
    // 管理器
    protected LogicalEffectManager effectManager;
    // 施加者物体
    protected GameObject originalGameObject;
    // 生存状态
    protected bool lifeState = true;
    // 是否来自自身
    protected bool isFromItselef;
    // 是否来自玩家
    protected bool isFromPlayer;
    // 初始化
    public virtual void Init(GameObject originalGameObject, params object[] args)
    {
        effectManager = GetComponent<LogicalEffectManager>();
        this.originalGameObject = originalGameObject;
        isFromItselef = originalGameObject == gameObject;
        isFromPlayer = originalGameObject.CompareTag("Player");
    }
    public virtual void SetData(LogicalEffectDataBase effectData)
    {
        this.effectData = effectData;
    }
    public virtual void InitDataFromExcel()
    {
        if (effectData.ExcelID != "")
        {
            effectData.GetExcelData();
        }
    }
    // 应用时
    public abstract void OnApply();
    // 移除时
    public virtual void OnRemove()
    {

    }
    // 刷新
    public virtual void OnRefresh() { }
    // 更新时
    public virtual void OnUpdate() { }
    // 完成时
    public virtual void OnComplete() 
    {
        OnRemove();
        Destroy(effectData);
        Destroy(this);
    }
    // 设置生存状态
    public virtual void SetLifeState(bool lifeState)
    {
        this.lifeState = lifeState;
    }
    // 得到生存状态
    public virtual bool GetLifeState()
    {
        return lifeState;
    }
}
